package com.旋转二维数组;

import java.util.HashMap;

public class Solution {

	public void rotate(int[][] matrix) {
		int temp=0;
		HashMap h = new HashMap();
		h.keySet();
		//对角线交换
        for(int i =0;i<matrix.length-1;i++) {
        	for(int j =i+1;j<matrix[0].length;j++) {
        		temp = matrix[i][j];
        		matrix[i][j] = matrix[j][i];
        		matrix[j][i] = temp;
        	}
        }
        //对角线交换完毕，接着要轴对称交换
        int temp1=0;
        for(int i=0;i<matrix.length;i++) {
        	for(int j=0;j<matrix[0].length/2;j++) {
        		temp1=matrix[i][j];
        		matrix[i][j] = matrix[i][matrix[0].length-1-j];
        		matrix[i][matrix[0].length-1-j] = temp1;
        	}
        }
        for(int i =0;i<matrix.length;i++) {
        	for(int j =0;j<matrix[0].length;j++) {
        		System.out.print(matrix[i][j]);
        	}
        	System.out.println();
        }
	}
	
	

}
